    function y = plotmodel(fig,model,mode,imgH)
    % fig is figure handle    
    
    
%         hold on;
        figure(fig);
        hold on;
        
        switch mode
            case 'math'
                for i=1:size(model,3),
                    plot(model(1,:,i),model(2,:,i));
                    hold on;
                end
                
            case 'image'                
                 for i=1:size(model,3),
                     % reference of coord trans
%                     r1 = -r1;
%                     r1 = r1 + size(BW,1);                               
                    plot(model(1,:,i), -model(2,:,i)+imgH);
                    hold on;
                 end
                
            otherwise
        end
        
        y = 1;
    end